Skip to main content

Postal details Rest API Design Document

Create a REST API which will accept customer Id as query parameter. Use that customer Id to fetch the data from Customer Database in order to get PIN code for that customer. Use this PIN code to get postal address details from India Post Rest API. Transform the response in the desired format to generate final response

Postal details Rest API:

Description:

It is an API which is used to get customer data from DB and use that data to get postal details from India Post API. We have the customer database and it has following no of columns in remote DB as shown below Customer’s table column name

FieldsData Types
IdInteger
first_namevarchar
last_namevarchar
addressvarchar
pinInteger
emailvarchar
loginvarchar
identifiervarchar

End-Points:

GET-returns specific record

SETP 1:

Login to Quick Integration Platform to get started.

;

STEP 2:

Click on Manage Option >> Projects >> Create to create the new project

; ;

Once project is created, below popup shows up.

;

STEP 3:

Go to DEVELOP >> Functionality API

;

STEP 4:

Select relevant project and create services in that project ; ;

STEP 5:

Once service name is provided, canvas will show up

;

STEP 6:

Left click on REST Trigger to Configure as given below.

;

FieldsDescriptionExamples
uriResource Path to trigger the API/getPostalinfo
typeMetods of The API like GET, PUT, PATCH, etcGET

STEP 7:

Drag UTILITY component to add start logger for you service.

;

STEP 8:

Left click on UTILITY Connector and Configure as given below.

;

Methods:

;

Log type:

;

Log Value:

Start Log - Start_level_log_info

STEP 9:

Drag URIVALIDATOR to validate the URL.

;

STEP 10:

Left click on URIVALIDATOR Connector and Configure as given below.

;

FieldsDescriptionExamples
Scenario-NameName of the scenario to be performed in case the validation failed.Validate_request
Request ParamsNames of the param keys passed in query parameters.ID

STEP 11:

Drag DB Connector to make DB call in the service.

;

STEP 12:

Add DB connectivity details in Connection properties:

;

;

STEP 13:

Left click on DB Connector and Configure as given below. Select the database configuration created in properties to DB connectivity in datasource name:

;

FieldsDescriptionExample
DB OperationRead/WriteRead
Datasource NameDatasource Name which is configured in connections propertiesdbds
Return Row(s)Single, MultipleSingle
Output VariableThis field is the variable name for which the output of the following step is store in the pipeline Data
QueryThis is the Database commandsSELECT pin FROM crm_customers WHERE id=:id

Let see how to write the query using quickintegration with few clicks

Select the table Name from the Droup down list, we can limit the number of records To be retrieved In filters add the condition for fields use in the query with the help of operation like NULL, NOT NULL, =, !=, etc Your Generated Query will get Created.

  1. Select the Table Name

;

  1. Select the Coloumn

;

  1. Select the Fields

;

  1. Select the Operations

;

FieldsDescriptionExample
Table NameData Base Table Namecrm_customers
Your Generated Query isData Base QuerySELECT pin FROM crm_customers WHERE id:id
Filters(Fields)Perticular field where DB will Operateid
Filters(Operation)Operations like NULL, NOT NULL, =, !=, etc=

STEP 14:

Define Global variables to be used in the service:

;

;

;

STEP 15:

Drag REST component to make India Post REST API call to get postal details based on PIN code.

;

STEP 16:

Left click on REST Connector and Configure as given below.

;

FieldsDescriptionExample
Http URLURL by which the API will be calleddburl
MethodFormats like GET, POST, DELETE, etcGET
Base PathResource Path/pincode/;pincode
SecurityTo be Defined in the propertioes like Basic Authentication, OAuth token, Authorization Code, etc
Output VariableStores output of connections operationspayload

Type: pathparam

Target: pincode

key: $Data.pin

STEP 17:

Drag APIRESPONSE component to map the response :

;

Click on the Drop down and select Content Type application json

;

Click on Add button and do the mapping as shown below

When we want to get a variable, from the pipeline, we use $ sign as prefix followed by Variable name from in the pipeline. There can be nested get which is seperated by '.' Ex. $Payload.key.

Note:- The variable Payload should be present in the pipeline before the calling

;

;

FieldsDescription
GENGet one field from the Input and mapped in another field of Output
TRANSTransforms the Input value with the help of transformation functions
CNMapped the Input as it is Output body
OBJMapped the Inputs to Object
ARMapped the Inputs to Array

STEP 18:

Drag UTILITY component to add end logger for you service

;

;

Methods:

;

Log type:

;

Log Value:

End Log - End_level_log_info

STEP 19:

Step Exception handling in the service:

Step error is specifically for particular connector error. Select the Step Exception handler from the palate, Drag it to the canvas and configure it for the DB and Rest error Please refer the configration shown below

;

;

FieldsDescriptionExample
MethodThis is the utility function to throw the error in the flowthrow error
Error TypeType of Exception thrown in the flow such as INTBuinessException and INTRetryException INTBuinessException
Exception messageThe custom message while throwing the custom Exception$VARIABLES.nocustomer
Exception codeThe code while throwing the Execption$VARIABLES.nocustomercode

STEP 20:

;

If DB does not return response for a customer Id, error message is created as “No customer found”. PFB the configuration for reference:

;

FieldsDescriptionExample
MethodThis is the utility function to throw the error in the flowthrow error
Error TypeType of Exception thrown in the flow such as INTBuinessException and INTRetryException INTBuinessException
Exception messageThe custom message while throwing the custom Exception$VARIABLES.invalidPin
Exception codeThe code while throwing the Execption $VARIABLES.errorPin

STEP 21:

Global Exception handling in the service:

Global Error is for the all the component in the flow. Select the Global Error from the palate, Drag it to the canvas and configure it as shown below

;

;

FieldsDescriptionExample
MethodThis is the utility function to throw the error in the flowthrow error
Error TypeType of Exception thrown in the flow such as INTBuinessException and INTRetryException INTBuinessException
Exception messageThe custom message while throwing the custom Exceptioncompulsory querry param not passed
Exception codeThe code while throwing the Execption$VARIABLES.noid

If any error occurs in the service during processing. It is handled in the global Exception handler.

STEP 22:

PFB the final service screenshot below :

;

STEP 23:

Step to Test the API Deployed on QuickIntegration.

  1. Save the application.
  2. Go to EXECUTE >> BUILD to Build the application.
  3. Deploy the application after build. Select the Application Name From Drop down, and pass the security key in Properties. Click on deploy application.
  4. Go to application and Bring UP the application by clicking on project.
  5. Provide the security key and start the API.
  6. Once you Successfully started your API, you will find Development URL in Details Coloumn
  7. Using the QuickIntegrate deployed URL You can Test your API using Postman Collection